home *** CD-ROM | disk | FTP | other *** search
/ Hobby PC 13 / Hobby PC 13.iso / assets / Asset Library / Dynamic HTML Utilities / Ticker Tape Field / tickertape.txt < prev   
Text File  |  2001-04-09  |  2KB  |  74 lines

  1. <SCRIPT ID="SQTicker" LANGUAGE="JavaScript">
  2. <!--
  3. function setupTicker(theMessage,fwidth,speed)
  4.     {
  5.     x = new Date(); formcount = x.getTime();
  6.     formName = "scrollForm" + formcount;
  7.     fieldName = "scrollField" + formcount;
  8.     if ((navigator.userAgent.indexOf("MSIE") == -1) && (navigator.userAgent.indexOf("msie") == -1))
  9.         {
  10.         fieldStyle = "";
  11.         }
  12.     else
  13.         {
  14.         fieldStyle = "Courier";
  15.         }
  16.     document.write('<FORM name="'+ formName + '"><INPUT NAME="' + fieldName + '" SIZE="' + fwidth + '" STYLE="font-family:' + fieldStyle + '"></FORM>');
  17.     eval("scrollText(document." + formName + "." + fieldName + ",theMessage,fwidth,speed,0,0,0)");
  18.     }
  19.  
  20. function scrollText(theField,theMessage,theWidth,theSpeed,scrollStart,scrollEnd,scrollCount)
  21.     {
  22.     theOtherField = theField;
  23.     if (scrollEnd < (theMessage.length))
  24.         {
  25.         theField.value = padTextPrefix(theMessage.substring(scrollStart,scrollEnd)," ",theWidth-scrollCount);
  26.         scrollEnd++;
  27.         }
  28.     else
  29.         {
  30.         scrollCount++;
  31.         theField.value = padTextSuffix(padTextPrefix(theMessage.substring(scrollStart,scrollEnd)," ",theWidth-scrollCount)," ",theWidth);
  32.         }
  33.     if (scrollCount == (parseInt(theWidth)-theMessage.substring(scrollStart,scrollEnd).length+1))
  34.         {
  35.         scrollStart++;
  36.         }
  37.       if (scrollStart == scrollEnd)
  38.         {
  39.         scrollStart = 0;
  40.         scrollEnd = 0;
  41.         scrollCount = 0;
  42.         }
  43.     scrollTimeout=eval("window.setTimeout('scrollText(theOtherField,\""+theMessage+"\"," + theWidth + "," + theSpeed + "," + scrollStart + "," + scrollEnd + "," + scrollCount + ")',theSpeed)");
  44.     }
  45.  
  46. function padTextPrefix (InString, PadChar, DefLength)
  47.     {
  48.     if (InString.length>=DefLength)
  49.         {
  50.         return (InString);
  51.         }
  52.     OutString = InString;
  53.     for (Count = InString.length; Count<DefLength; Count++)
  54.         {
  55.         OutString=PadChar+OutString
  56.         }
  57.     return (OutString);
  58.     }
  59.  
  60. function padTextSuffix (InString, PadChar, DefLength)
  61.     {
  62.     if (InString.length >= DefLength)
  63.         {
  64.         return (InString);
  65.         }
  66.     OutString = InString;
  67.     for (Count = InString.length; Count<DefLength; Count++)
  68.         {
  69.         OutString = OutString + PadChar
  70.         }
  71.     return (OutString);
  72.     }
  73. // -->
  74. </SCRIPT>